
const origin = [
  // { image: 'refill', text: '充值', url: 'refill'},
  { image: 'qrcode', text: '推荐码', url: 'qr-code' },
  // { image: 'sign-in', text: '签到', url: 'sign-in' },
  { image: 'team', text: '我的团队', url: 'team' },
  { image: 'commission', text: '我的佣金', url: 'commission' },
  // { image: 'identity-card', text: '业绩', url: 'performance' },
  { image: 'cash', text: '提现管理', url: 'cash' },
  { image: 'group', text: '我的抽奖', url: 'award' },
  { image: 'password', text: '支付密码', url: 'pay-password' },
  { image: 'bank', text: '默认银行卡', url: 'bank' },
  { image: 'address', text: '地址管理', url: 'address-list' },
  // { image: 'rank', text: '排行榜', url: 'rank' },
  // { image: 'group', text: '申请区代', url: 'area-reg' },
]

Component({
  properties: {
    is_area: {
      type: Boolean,
      default: false,
      // observer(newVal, oldVal, changedPath) {
      //   // console.log(newVal, 1111111)
      //   if (newVal) {
      //     const list = [...origin]
      //     // list.push({ image: 'group', text: '申请区代', url: 'area-reg' })
      //     this.setData({
      //       list
      //     })
      //   } else {
      //     this.setData({
      //       list: [
      //         { image: 'qrcode', text: '推荐码', url: 'qr-code' },
      //         { image: 'address', text: '地址管理', url: 'address-list' },
      //       ]
      //     })
      //   }
      // }
    },
    wx: {
      type: Boolean,
      default: false,
      observer(newVal, oldVal, changedPath) {
        if (!newVal) {
          const list = [...origin]
          this.setData({
            list
          })
        } else {
          this.setData({
            list: [
                  { image: 'qrcode', text: '推荐码', url: 'qr-code' },
                  { image: 'address', text: '地址管理', url: 'address-list' },
                ]
          })
        }
      }
    }
  },
  data: {
    list: [...origin]
  },
  methods: {
    handleClick(event) {
      const item = event.currentTarget.dataset.item
      const url = item.url

      if (url == 'award') {
        wx.navigateTo({
          url: '/sub_main/pages/award/index?id=2'
        })
      }
      else if (url == 'area-reg') {
        this.triggerEvent('regArea')
      } else {
        wx.navigateTo({
          url: `/sub_service/pages/${url}/index`
        })
      }
    }
  }
});
